* When does accommodation fail? The electoral consequences of intra-party divisions and mainstream party strategies
* Felix Lehmann
* Department of Political Science, University of Gothenburg
* felix.lehmann@gu.se; Sprängkullsgatan 19, Box 711, 411 23 Göteborg, Sweden

* Replication file for the main analysis


* save all replication files in the same folder structure
* change the working directory to the designated folder structure
*cd "C:\..."
* 


use "Accommodation_failure_election_level_data.dta", clear


* Figure 1
set scheme plotplain

// specification reported by Krause (2020), party FEs with election and party clusters
reghdfe pervote vote_lag eu_dissent eu_position_change_rev c.eu_dissent#c.eu_position_change_rev government eu_salience_change if mainstream_narrow == 1 & wecee14 == 1, absorb(party_id) cluster(party_id election_id)

keep if e(sample) == 1

margins, dydx(eu_position_change_rev) at(eu_dissent=(0(1)10))
marginsplot, ytitle(Marginal effect of Δ EU position on mainstream vote, size(small)) xtitle(EU intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title("") level(90) yline(0) note("90% CIs", pos(5) size(vsmall)) ///
addplot(hist eu_dissent, yscale(r(-3 0) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-4(1)2) ///
xlabel(0(1)10) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off))

graph export "Figure1.png", replace

* Figure 2
* Meso-level analysis with party dyads

use "Accommodation_failure_dyadic_level_data.dta", clear

eststo clear
set scheme plotplain

mixed vote_switch2 eu_dissent eu_position_change_rev c.eu_dissent#c.eu_position_change_rev government vote_lag eu_salience_change avg_pos_eu_rev_change avg_sal_eu_change gdp_cap_growth_lag1 unemployment_lag1 eff_parties_corr adm if mainstream_narrow == 1 || country2: || election_id: || party_election_id:
keep if e(sample) == 1

margins, dydx(eu_position_change_rev) at(eu_dissent=(0(1)10))
marginsplot, ytitle(Marginal effect of Δ EU position on dyadic vote gains, size(small)) xtitle(EU intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title("") level(90) yline(0) note("90% CIs", pos(5) size(vsmall)) ///
addplot(hist eu_dissent, yscale(r(-2 1.5) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-2(0.5)1.5) ///
xlabel(0(1)10) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off))

graph export "Figure2.png", replace

* Figure 3

use "Accommodation_failure_dyadic_level_data.dta", clear

eststo clear
set scheme plotplain

mixed vote_switch2 eu_dissent eu_position_change_rev c.eu_dissent#c.eu_position_change_rev government vote_lag eu_salience_change avg_pos_eu_rev_change avg_sal_eu_change gdp_cap_growth_lag1 unemployment_lag1 eff_parties_corr adm if mainstream_narrow == 1 & eurosceptic_dyad == 1 || country2: || election_id: || party_election_id:
keep if e(sample) == 1

margins, dydx(eu_position_change_rev) at(eu_dissent=(0(1)10))
marginsplot, ytitle(Marginal effect of Δ EU position on dyadic vote gains, size(small)) xtitle(EU intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title((A) Vote gains vs. Eurosceptic, size(med)) level(90) yline(0) ///
addplot(hist eu_dissent, yscale(r(-2 2) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-2(1)2) ///
xlabel(0(1)10) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off))

graph save g1, replace

use "Accommodation_failure_dyadic_level_data.dta", clear

eststo clear
set scheme plotplain

mixed vote_switch2 eu_dissent eu_position_change_rev c.eu_dissent#c.eu_position_change_rev government vote_lag eu_salience_change avg_pos_eu_rev_change avg_sal_eu_change gdp_cap_growth_lag1 unemployment_lag1 eff_parties_corr adm if mainstream_narrow == 1 & eurosceptic_dyad != 1 || country2: || election_id: || party_election_id:
keep if e(sample) == 1

margins, dydx(eu_position_change_rev) at(eu_dissent=(0(1)10))
marginsplot, ytitle(Marginal effect of Δ EU position on dyadic dyadic vote gains, size(small)) xtitle(EU intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title((B) Vote gains vs. non-Eurosceptic, size(med)) level(90) yline(0) ///
addplot(hist eu_dissent, yscale(r(-2 2) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-2(1)2) ///
xlabel(0(1)10) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off))

graph save g2, replace

graph combine "g1" "g2", note("90% CIs", pos(5) size(vsmall)) row(1)

graph export "Figure3.png", replace

* Immigration issue
* Figure 4

use "Accommodation_failure_dyadic_level_data2.dta", clear

eststo clear
set scheme plotplain

mixed vote_switch2 immigrate_dissent immigration_position_change c.immigrate_dissent#c.immigration_position_change government vote_lag avg_pos_imm_change gdp_cap_growth_lag1 unemployment_lag1 eff_parties_corr adm if mainstream_narrow == 1 || country2: || election_id: || party_election_id:
keep if e(sample) == 1

margins, dydx(immigration_position_change) at(immigrate_dissent=(1(1)7))
marginsplot, ytitle(Marginal effect of Δ immigration position on dyadic vote gains, size(small)) xtitle(Immigration intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title("") level(90) yline(0) note("90% CIs", pos(5) size(vsmall)) ///
addplot(hist immigrate_dissent, yscale(r(-2 3) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-2(1)3) ///
xlabel(1(1)7) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off))

graph export "Figure4.png", replace

* Figure 5

use "Accommodation_failure_dyadic_level_data2.dta", clear

eststo clear
set scheme plotplain

mixed vote_switch2 immigrate_dissent immigration_position_change c.immigrate_dissent#c.immigration_position_change government vote_lag avg_pos_imm_change gdp_cap_growth_lag1 unemployment_lag1 eff_parties_corr adm if mainstream_narrow == 1 & rr_dyad == 1 || country2: || election_id: || party_election_id:
keep if e(sample) == 1

margins, dydx(immigration_position_change) at(immigrate_dissent=(1(1)7))
marginsplot, ytitle(Marginal effect of Δ immigration position on dyadic vote gains, size(small)) xtitle(Immigration intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title((A) Vote gains vs. radical right, size(med)) level(90) yline(0) ///
addplot(hist immigrate_dissent, yscale(r(-2 3) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-2(1)3) ///
xlabel(1(1)7) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off))

graph save g1, replace

use "Accommodation_failure_dyadic_level_data2.dta", clear

eststo clear
set scheme plotplain

mixed vote_switch2 immigrate_dissent immigration_position_change c.immigrate_dissent#c.immigration_position_change government vote_lag avg_pos_imm_change gdp_cap_growth_lag1 unemployment_lag1 eff_parties_corr adm if mainstream_narrow == 1 & rr_dyad != 1 || country2: || election_id: || party_election_id:
keep if e(sample) == 1

margins, dydx(immigration_position_change) at(immigrate_dissent=(1(1)7))
marginsplot, ytitle(Marginal effect of Δ immigration position on dyadic vote gains, size(small)) xtitle(Immigration intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title((B) Vote gains vs. non-radical right, size(med)) level(90) yline(0) ///
addplot(hist immigrate_dissent, yscale(r(-2 3) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-2(1)3) ///
xlabel(1(1)7) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off))

graph save g2, replace

graph combine "g1" "g2", note("90% CIs", pos(5) size(vsmall)) row(1)

graph export "Figure5.png", replace

* Mechanism tests
* Figure 6

use "Accommodation_failure_party_like.dta", clear

eststo clear

reghdfe party_like eu_dissent eu_position_change_rev c.eu_dissent#c.eu_position_change_rev government eu_salience_change if mainstream_narrow == 1 & wecee14 == 1, absorb(party_id) cluster(election_id party_id)
keep if e(sample) == 1

margins, dydx(eu_position_change_rev) at(eu_dissent=(0(0.5)10))
marginsplot, ytitle(Marginal effect of Δ EU position on party likeability, size(small)) xtitle(EU intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title("") level(90) yline(0) note("90% CIs", pos(5) size(vsmall)) ///
addplot(hist eu_dissent, yscale(r(-1 0.5) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-1(0.5)0.5) ///
xlabel(0(1)10) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off) ytitle("Distribution of EU intra-party divisions", axis(2) size(small)))

graph export "Figure6.png", replace


* Figure 7

use "Accommodation_failure_party_cue.dta", clear

reghdfe eu_public_change_rev_ees eu_position_change_rev eu_dissent c.eu_position_change_rev#c.eu_dissent government eu_salience_change if mainstream_narrow == 1 & wecee14 == 1, absorb(party_id) cluster(election_id party_id)
keep if e(sample) == 1

margins, dydx(eu_position_change_rev) at(eu_dissent=(0(1)10))
marginsplot, ytitle(Marginal effect of Δ EU position on voter Δ EU position, size(small)) xtitle(EU intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title("(A) Δ Public", size(large)) level(90) yline(0) ///
addplot(hist eu_dissent, yscale(r(-1 1) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-1(0.5)1) ///
xlabel(0(1)10) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off) ytitle("Distribution of EU intra-party divisions", axis(2) size(small)))

graph save g1, replace 

use "Accommodation_failure_party_cue.dta", clear

reghdfe eu_public_supp_change_rev_ees eu_position_change_rev eu_dissent c.eu_position_change_rev#c.eu_dissent government eu_salience_change if mainstream_narrow == 1 & wecee14 == 1, absorb(party_id) cluster(election_id party_id)
keep if e(sample) == 1

margins, dydx(eu_position_change_rev) at(eu_dissent=(0(1)10))
marginsplot, ytitle(Marginal effect of Δ EU position on supporter Δ EU position, size(small)) xtitle(EU intra-party divisions) recast(line) recastci(rarea) ci1opt(fcolor(midblue%40) lcolor(midblue%40)) title("(B) Δ Supporter", size(large)) level(90) yline(0)  ///
addplot(hist eu_dissent, yscale(r(-1 1) axis(1)) ylab(0(0.2)1, axis(2)) ylab(-1(0.5)1) ///
xlabel(0(1)10) yaxis(2) ysc(axis(2) off alt) ///
fcolor(dkgreen%30) lcolor(dkgreen%30) legend(off) ytitle("Distribution of EU intra-party divisions", axis(2) size(small)))

graph save g2, replace 

graph combine "g1" "g2", note("90% CIs", pos(5) size(vsmall))

graph export "Figure7.png", replace


